<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools"></t:base>
<script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.js"></script>
<link rel="stylesheet" type="text/css" href="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<div id="main_typegroup_list" class="easyui-layout" fit="true">
  <div region="center" style="padding: 1px;">
    <t:datagrid name="officialWhList"  fitColumns="false" title="" actionUrl="officialWhController.do?datagrid" onDblClick="preview"
                fit="true" idField="articleId"  queryMode="group" onLoadSuccess="loadSuccess">
      <t:dgCol title="id" field="articleId" hidden="true"></t:dgCol>
      <t:dgCol title="文章标题"   field="title" query="true"></t:dgCol>
      <t:dgCol title="作者名称"   field="consumerName" query="true"></t:dgCol>
      <t:dgCol title="分类标签"   field="factorColumnName" sortable="false" ></t:dgCol>
      <t:dgCol title="分类标签"   field="columns"  hidden="true"></t:dgCol>
      <t:dgCol title="文章类型"  field="articleType"  dictionary="articleType" ></t:dgCol>
      <t:dgCol title="文章发布者"   field="publisher.realName" ></t:dgCol>
      <t:dgCol title="文章发布时间"  formatter="yyyy-MM-dd hh:mm:ss" field="publishTime"></t:dgCol>
      <%--<t:dgCol title="文章编写时间"  formatter="yyyy-MM-dd hh:mm:ss" field="writeTime"></t:dgCol>--%>
      <%--<t:dgCol title="来源"  field="source" dictionary="sourceType" query="true"></t:dgCol>--%>
      <%--<t:dgCol title="来源头像" extendParams="formatter:LogoFormatter;" field="sourceAvatar" ></t:dgCol>--%>
      <%--<t:dgCol title="来源地址"  field="sourceUrl"></t:dgCol>--%>
      <%--<t:dgCol title="阅读次数"  field="readNum"  ></t:dgCol>--%>
      <%--<t:dgCol title="跟帖数量"  field="commentNum"  ></t:dgCol>--%>
      <%--<t:dgCol title="版式"  field="format" dictionary="formatType" ></t:dgCol>--%>
      <%--<t:dgCol title="是否轮播"  field="isCarousel" dictionary="isno" ></t:dgCol>--%>
      <t:dgCol title="审核"  field="status" dictionary="review" query="true" ></t:dgCol>
      <%--<t:dgCol title="文章主图" extendParams="formatter:LogoFormatter;" field="articleThumb" ></t:dgCol>--%>
      <%--<t:dgCol title="图一" extendParams="formatter:LogoFormatter;" field="pic1" ></t:dgCol>--%>
      <%--<t:dgCol title="图二" extendParams="formatter:LogoFormatter;" field="pic2" ></t:dgCol>--%>
      <%--<t:dgCol title="图三" extendParams="formatter:LogoFormatter;" field="pic3" ></t:dgCol>--%>
      <%--<t:dgCol title="好赞"  field="praiseNum" ></t:dgCol>--%>
      <%--<t:dgCol title="关键字"  field="keyword" query="true"></t:dgCol>--%>

      <%--<t:dgCol title="创建时间"  formatter="yyyy-MM-dd hh:mm:ss" field="createTime"></t:dgCol>--%>

      <t:dgCol title="common.operation" field="opt" ></t:dgCol>
      <t:dgDelOpt operationCode="deleteOfficialWh" url="officialWhController.do?delOfficialWh&id={articleId}" title="删除"></t:dgDelOpt>
      <t:dgConfOpt operationCode="yesOpt"  title="审核通过" message="是否确定审核通过该文章?" url="officialWhController.do?statusOfficialWh&id={articleId}&status=1" exp="status#eq#0" ></t:dgConfOpt>
      <t:dgConfOpt operationCode="noOpt"  title="审核不通过" message="是否确定审核不通过该文章?" url="officialWhController.do?statusOfficialWh&id={articleId}&status=2" exp="status#eq#0"  ></t:dgConfOpt>
      <%--<t:dgFunOpt operationCode="columnOfficialWh"  title="栏目" funname="f_optLm(articleId)" ></t:dgFunOpt>--%>
      <%--<t:dgFunOpt operationCode="specialOfficialWh"  title="加入专题" funname="f_optAddSpecial(articleId)" ></t:dgFunOpt>--%>

      <t:dgToolBar operationCode="editOfficialWh"  title="新增" langArg="common.user" icon="icon-add" url="officialWhController.do?addorupdate" width="800"  funname="f_add"></t:dgToolBar>
      <t:dgToolBar operationCode="editOfficialWh"  title="修改" langArg="common.user" icon="icon-edit" url="officialWhController.do?addorupdate" width="800"  funname="f_updateOfficial"></t:dgToolBar>
      <t:dgToolBar operationCode="viewOfficialWh"  title="预览" langArg="common.user" icon="icon-edit" url="officialWhController.do?getOfficialWh" width="800"  funname="f_getOfficial"></t:dgToolBar>
    </t:datagrid>
  </div>
</div>

<div data-options="region:'east',
	title:'mytitle',
	collapsed:true,
	split:true,
	border:false,
	onExpand : function(){
		li_east = 1;
	},
	onCollapse : function() {
	    li_east = 0;
	}"
     style="width: 400px; overflow: hidden;" id="eastPanel">
  <div class="easyui-panel" style="padding: 1px;" fit="true" border="false" id="userListpanel"></div>
</div>

<script type="text/javascript">

  $(function() {
    var li_east = 0;
  });

  /**
   * 重写 更新事件打开窗口
   * @param title 编辑框标题
   * @param addurl//目标页面地址
   * @param id//主键字段
   */
  function f_add(title,url, id,width,height) {

    gridname=id;
    createwindow(title,url,width,500);
  }

  /**
   * 重写 更新事件打开窗口
   * @param title 编辑框标题
   * @param addurl//目标页面地址
   * @param id//主键字段
   */
  function f_updateOfficial(title,url, id,width,height) {
    gridname=id;
    var rowsData = $('#'+id).datagrid('getSelections');
    if (!rowsData || rowsData.length==0) {
      tip('请选择编辑项目');
      return;
    }
    if (rowsData.length>1) {
      tip('请选择一条记录再编辑');
      return;
    }

    url += '&articleId='+rowsData[0].articleId;
//    createwindow(title,url,width,height);
    openwindow(title,url,"officialWhList",width,500);
  }
  function f_getOfficial(title,url, id,width,height) {
    gridname=id;
    var rowsData = $('#'+id).datagrid('getSelections');
    if (!rowsData || rowsData.length==0) {
      tip('请选择编辑项目');
      return;
    }
    if (rowsData.length>1) {
      tip('请选择一条记录再编辑');
      return;
    }

    url += '&articleId='+rowsData[0].articleId;
    openwindow(title,url,gridname,width,500);
  }

  function preview(rowIndex,rowData) {
    openwindow("预览",'officialWhController.do?getOfficialWh&articleId='+rowData.articleId, "officialWhList",800,500);
  }

  function LogoFormatter(val,row){
    if(val != null && val != "" && val != undefined){
      val += "?" + new Date().getTime();
    }
    return '<a rel="datagrid_group" href="'+val+'" title=""><img alt="" src="'+val+'"  style="width:30px;height:30px;"></a>';
  }

  function articleImg(){
    $("a[rel=datagrid_group]").fancybox({
      'overlayShow'	: false,
      'transitionIn'	: 'elastic',
      'transitionOut'	: 'elastic'
    });
  }

  function loadSuccess() {
    articleImg();
    $('#main_typegroup_list').layout('panel','east').panel('setTitle', "");
    $('#main_typegroup_list').layout('collapse','east');
    $('#userListpanel').empty();
  }

  function f_optDmt(articleId){

    var rowsData = $('#officialWhList').datagrid('getSelections');
    setTimeout(function(){

      var title = "《" + rowsData[0].title + '》的多媒体';

      if(title.length > 23){

        title = title.substring(0,23) + "...";
      }

      if(li_east == 0){
      $('#main_typegroup_list').layout('expand','east');
      }
      $('#main_typegroup_list').layout('panel','east').panel('setTitle', title);
      $('#userListpanel').panel("refresh", "officialMediaController.do?officialMediaList&articleId=" + articleId);

    },10);

  }
  function f_optLm(articleId){

    var rowsData = $('#officialWhList').datagrid('getSelections');
    setTimeout(function(){
      var title = "《" + rowsData[0].title + '》的所属栏目';

      if(title.length > 23){

        title = title.substring(0,23) + "...";
      }

      if(li_east == 0){
        $('#main_typegroup_list').layout('expand','east');
      }
      $('#main_typegroup_list').layout('panel','east').panel('setTitle', title);
      $('#userListpanel').panel("refresh", "officialColumnsController.do?officialColumnsList&articleId=" + articleId);
    },10);
  }

  //多媒体格式化数据
  function mediaImgFormatter(val,row){

    var html="";

    var type = row.type;
    if(type != ""){

      type = parseInt(type);

    }
    switch (type){
      case 101:
        html=  '<a rel="example_group" href="'+val+'" title="'+row.alt+'"><img style="width: 30px;height: 30px;" alt="" src="'+val+'" /></a>'

        break;
      case 102:
        html=  '<a href=\'javascript:f_openPlayer("'+val+'");\' title="'+row.alt+'"><img style="width: 30px;height: 30px;" alt="" src="${defVideoImg}" /></a>'


        break;
      case 103:

        html=  '<a rel="example_group" href="'+val+'" title="'+row.alt+'"><img style="width: 30px;height: 30px;" alt="" src="${defFileImg}" /></a>'


        break;
      default :

        html=  '<a rel="example_group" href="${defImgUrl}" title="多媒体类型未定义"><img style="width: 30px;height: 30px;" alt="" src="${defImgUrl}" /></a>'

        break;

    }

    return html;


  }
  //打开专题列表
  function f_optAddSpecial(articleId){

    add("加入专题","officialWhController.do?miniSpecialList&articleId="+articleId,"officialWhList",800,500)

  }


  function f_getPreviousId(){



//    var xx = $('#officialWhList').datagrid('selectRow');

    var rowIndex=$('#officialWhList').datagrid('getRowIndex',$('#officialWhList').datagrid('getSelected'))

    if(rowIndex == 0){//没有上一条了
      return "";
    }

    $('#officialWhList').datagrid('selectRow',rowIndex - 1);

    var rowsData = $('#officialWhList').datagrid('getSelections');

    return rowsData[0].articleId;
  }
  function f_getNextId(){




    var rowIndex=$('#officialWhList').datagrid('getRowIndex',$('#officialWhList').datagrid('getSelected'))

    //没有下一条了
    if($('#officialWhList').datagrid('getRows').length == (rowIndex + 1)){

      return "";

    }

    $('#officialWhList').datagrid('selectRow',rowIndex + 1);

    var rowsData = $('#officialWhList').datagrid('getSelections');

    return rowsData[0].articleId;

  }

  //快捷按钮操作
  function f_optButton(fname,buttonName){

    var isBoo = false;

    $("#officialWhListtb a").each(function(i){

      if($(this).html().indexOf(buttonName) > 0){

        $("iframe[name="+fname+"]",parent.document)[0].contentWindow.f_closeWindow();

        $(this).trigger("click");
        isBoo = true;
      }

    });

    return isBoo;

  }

</script>
